<script setup>
import { ref, watch } from 'vue';
import { getSearchSuggestions } from "@/api/search";

// eslint-disable-next-line no-undef
const props = defineProps({
  searchText: {
    type: String,
    required: true,
    default: ''
  }
});

const suggestions = ref([]);

watch(() => props.searchText, async (newSearchText) => {
  const { data } = await getSearchSuggestions(newSearchText);
  console.log(data);
  suggestions.value = data.data.options;
}, {
  immediate: true
});
</script>


<template>
  <div>
    <van-cell
        icon="search"
        :title="str"
        v-for="(str,index) in suggestions"
        :key="index"
    >
    </van-cell>
  </div>
</template>

<style scoped>

</style>